﻿using Microsoft.Xna.Framework;

namespace RaptorEngine.Components
{
	public class Movable : Component
	{
		public Vector3 Velocity { get; set; }
		public Vector3 Acceleration { get; set; }
		public float Mass { get; set; }
		public Vector3 Force
		{
			get { return Mass * Acceleration; }
		}

		public Movable(Entity entity, float mass)
			: base(entity, ComponentType.Movable)
		{
			Velocity = Vector3.Zero;
			Acceleration = Vector3.Zero;
			Mass = mass;
		}

		public void Update(GameTime gt)
		{
			float dT = gt.ElapsedGameTime.Milliseconds;

			Acceleration /= Mass;
			Velocity += Acceleration + GameEngine.Instance.Physics.Gravity;

			//Sets the new position based on the velocity and timestep.
			Entity.Position += Velocity * dT;


		}
	}
}
